import ajax from './ajax.js'
//从地址栏获取请求参数，并作为AJAX请求的参数一并发送
const href = window.location.href;
const params = href.substring(href.indexOf('?')+1);
const dataArr = params.split('=');

const inputs = document.querySelectorAll('input');

//通过id发送AJAX获取数据，渲染到表单
ajax.get('http://localhost:65535/getEdit',(value) => {
    const obj = JSON.parse(value)[0];
    inputs[0].value = obj._id;
    inputs[1].value = obj.name;
    inputs[2].value = obj.description;
    inputs[3].value = obj.profession;
    inputs[4].value = obj.price;
    
}, {[dataArr[0]]:dataArr[1]});